package com.sky.service.impl;


import com.sky.result.Result;
import com.sky.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional//开启事务
public class ShopServiceImpl implements ShopService {

    private final static String key = "SHOP_STATUS";

    @Autowired(required = false)
    StringRedisTemplate redisTemplate;



    /**
     * admin营业状态设置
     *
     * @param status
     * @return
     */
    @Override
    public Result updateStatus(Integer status) {
        redisTemplate.opsForValue().set(key,status.toString());
        return Result.success();
    }

    /**
     * admin营业状态查看
     *
     * @return
     */
    @Override
    public Result getStatus() {
        String status = redisTemplate.opsForValue().get(key);
        return Result.success(Integer.parseInt(status));
    }
}
